rm(list = ls())

library(tidyverse)

which_panel <- "SH"
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
path2sourceFile <- getwd()

inp_pred <- read_csv(paste("input_data/", which_panel, "_prediction_data_app.csv",sep=""))

outp_pred <- read_csv(paste("predictions/", which_panel, "_predictions.csv",sep=""))

outp_pred$X1 <- NULL

l_col_names <- colnames(outp_pred)
for (ii in 1:length(l_col_names)) {
  l_col_names[ii] <- paste(which_panel,toString(as.double(l_col_names[ii])+1),sep="")
}
colnames(outp_pred) <- l_col_names

list_pred_labels <- rep(0,nrow(outp_pred))

for (ii in 1:length(list_pred_labels)) {
  a <- which.max(outp_pred[ii,])
  list_pred_labels[ii] <- names(a)
}

outp_pred$predLabels <- list_pred_labels

fin_output <- cbind(inp_pred,outp_pred)

write_csv(fin_output,paste("RCN_predictions/",which_panel,"_predictions_ext.csv",sep=""))
